import request from '@/utils/request';

// 登录方法
export function login(username, password, code, uuid) {
  var headers = {};
  headers.isToken = false;
  const data = {
    username,
    password,
    code,
    uuid,
  };
  return request({
    url: '/login',
    method: 'post',
    data: data,
    headers: headers,
  });
}

// 登录方法
export function adminLogin(username, password, code, uuid) {
  var headers = {};
  headers.isToken = false;
  const data = {
    username,
    password,
    code,
    uuid,
  };
  return request({
    url: '/adminLogin',
    method: 'post',
    data: data,
    headers: headers,
  });
}

// 管理员短信登录方法
export function smsLogin(username, password, code, uuid) {
  var headers = {};
  headers.isToken = false;
  const data = {
    username,
    password,
    code,
    uuid,
  };
  return request({
    url: '/smsLogin',
    method: 'post',
    data: data,
    headers: headers,
  });
}

// 普通用户获取用户详细信息
export function getInfoOfApp() {
  return request({
    url: '/getInfoOfApp',
    method: 'get',
  });
}

// 获取用户详细信息
export function getInfo() {
  return request({
    url: '/getInfo',
    method: 'get',
  });
}

// 退出方法
export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  });
}

// 获取验证码
export function getCodeImg() {
  var headers = {};
  headers.isToken = false;
  return request({
    url: '/captchaImage',
    method: 'get',
    headers: headers,
  });
}

// 获取手机验证码
export function getPhoneSMS(phone) {
  var headers = {};
  headers.isToken = false;
  return request({
    url: '/sms/getSmsCode/' + phone,
    method: 'post',
    headers: headers,
  });
}

// 校验手机号码
export function checkPhone(phone) {
  var headers = {};
  headers.isToken = false;
  return request({
    url: '/sms/checkPhone/' + phone,
    method: 'post',
    headers: headers,
  });
}

// 判断验证码正确性
export function checkSMS(data) {
  var headers = {};
  headers.isToken = false;
  return request({
    url: '/register/compareSmsCode',
    method: 'post',
    data: data,
    headers: headers,
  });
}

// 重置密码
export function resetPwd(data) {
  var headers = {};
  headers.isToken = false;
  return request({
    url: '/register/resetPwd',
    method: 'post',
    data: data,
    headers: headers,
  });
}
